package com.neuedu.controller;

import com.neuedu.bean.Book;
import com.neuedu.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

//@Controller
//@ResponseBody

@RestController
@RequestMapping("/book")
@CrossOrigin
public class BookController {

    @Autowired
    BookService bookService;
    @RequestMapping("/findAllBook")
    public Map<String,Object> findAllBook(){
        List<Book> books = bookService.selectAllBook();
        HashMap<String, Object> resultMap = new HashMap<>();
        resultMap.put("code", 200);
        resultMap.put("books", books);
        return resultMap;
//        return books;
    }
  /*  @RequestMapping("/findAllBook")
    public List<Book> findAllBook(){
        List<Book> books = bookService.selectAllBook();
        return books;
    }*/
}
